package code;

public class Arrays {
    public static String toString(int[] arr){
        if(arr == null){
            return "null";
        }
        if(arr.length == 0){
            return "[]";
        }
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for(int i=0;i<arr.length;i++){
            sb.append(arr[i]);
            if(arr.length != i + 1){
                sb.append(",");
            }
        }
        sb.append("]");
        return sb.toString();
    }

    public static void main(String[] args) {
        final int[] a = {1,2,3,4};
        System.out.println(Arrays.toString(a));
        System.out.println(Arrays.toString(null));
        System.out.println(Arrays.toString(new int[0]));
    }
}
